<template>
  <van-form @submit="edit">
    <h3>修改会员信息</h3>
    <el-divider></el-divider>
    <van-field
        v-model="id"
        name="用户ID"
        readonly
        label="用户ID"
        placeholder="用户ID"
        :rules="[{ required: true, message: '请填写用户ID' }]"
    />
    <van-field
        v-model="name"
        name="用户名"
        readonly
        label="用户名"
        placeholder="用户名"
        :rules="[{ required: true, message: '请填写用户名' }]"
    />
    <van-field
        v-model="lxfs"
        name="联系方式"
        label="联系方式"
        placeholder="联系方式"
        :rules="[{ required: true, message: '请填写联系方式' }]"
    />
    <van-field
        v-model="qx"
        name="用户权限"
        label="用户权限"
        placeholder="用户权限"
        :rules="[{ required: false, message: '请填写用户权限' }]"
    />
    <div style="margin: 16px;" class="text-center visible-lg visible-md">
      <van-button round type="info" native-type="submit" style="width: 30%;">修改</van-button>
    </div>
    <div style="margin: 16px;" class="text-center visible-sm visible-xs">
      <van-button round type="info" native-type="submit" style="width: 70%;">修改</van-button>
    </div>
  </van-form>
</template>

<script>
import qs from 'qs'
import {setUserInfo} from "../../utils/api";
export default {
  name: "UserEdit",
  created() {
    let { lxfs,qx,name,id } = this.$route.params.valuse;
    this.qx=qx;
    this.lxfs=lxfs;
    this.name=name;
    this.id=id;
  },
  data(){
    return {
      id:'',
      name:'',
      qx:'',
      lxfs:''
    }
  },
  methods:{
    edit(){
      this.$dialog.confirm({
        message: '您确定要修改了吗？',
      }).then(() => {
        setUserInfo(qs.stringify({id:this.id,lxfs:this.lxfs,qx:this.qx})).then(respose=>{
          if(respose.status===200){
            this.$toast.success("修改成功");
            this.$router.go(-1);
          }else{
            this.$toast.fail("修改失败")
          }
        }).catch(error=>{
          console.log(error);
        })
      }).catch(() => {})
    }
  }
}
</script>

<style scoped>

</style>